<?php

/**

 * @package     Joomla.Administrator

 * @subpackage  com_units

 *

 * @copyright   Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.

 * @license     GNU General Public License version 2 or later; see LICENSE.txt

 */



// no direct access

defined('_JEXEC') or die;

// load tooltip behavior

JHtml::_('behavior.tooltip');

JHtml::_('behavior.tooltip');

JHtml::_('behavior.multiselect');



$user		= JFactory::getUser();

$userId		= $user->get('id');

$listOrder	= $this->escape($this->state->get('list.ordering'));

$listDirn	= $this->escape($this->state->get('list.direction'));

$canOrder	= $user->authorise('core.edit.state', 'com_regions.units');

$saveOrder	= $listOrder=='a.ordering';

$params		= (isset($this->state->params)) ? $this->state->params : new JObject();



?>



<form action="<?php echo JRoute::_('index.php?option=com_regions&view=regions'); ?>" method="post" name="adminForm">
<fieldset id="filter-bar">
		

			<select name="filter_country_id" class="inputbox" onchange="this.form.submit()" style="float:right">
				<option value=""><?php echo JText::_('COM_REGIONS_SELECT_COUNTRY');?></option>
				<?php echo JHtml::_('select.options', RegionsHelper::getCountryOptions(), 'value', 'text', $this->state->get('filter.country_id'));?>
			</select>
	<br clear="all" />
</fieldset>

  <table class="adminlist">

    <thead>

      <tr>

        <th width="5">#</th>

        <th width="20"> <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" />

        </th>

        <th> <?php echo JHtml::_('grid.sort', 'COM_REGIONS_HEADING_TITLE', 'a.title', $listDirn, $listOrder); ?></th>


		<th width="5%">

			<?php echo JHtml::_('grid.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>

		</th>

		<th width="10%">

			<?php echo JHtml::_('grid.sort',  'JGRID_HEADING_ORDERING', 'a.ordering', $listDirn, $listOrder); ?>

			<?php if ($canOrder && $saveOrder): ?>

			<?php echo JHtml::_('grid.order',  $this->items, 'filesave.png', 'regions.saveorder'); ?>

			<?php endif;?>

		</th>

		<th width="10%">

			<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_CREATED', 'a.created', $listDirn, $listOrder); ?>

		</th>

		<th width="5%">

			<?php echo JHtml::_('grid.sort', 'COM_REGIONS_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>

		</th>

      </tr>

    </thead>

    <tfoot>

      <tr>

        <td colspan="8"><?php echo $this->pagination->getListFooter(); ?></td>

      </tr>

    </tfoot>

    <tbody>

      <?php 

	  foreach($this->items as $i => $item): 

		$ordering	= ($listOrder == 'ordering');

		$canCreate	= $user->authorise('core.create',		'com_regions.regions.'.$item->id);

		$canEdit	= $user->authorise('core.edit',			'com_regions.regions.'.$item->id);

		$canChange	= $user->authorise('core.edit.state',	'com_regions.regions.'.$item->id);

	  

	  ?>

      <tr class="row<?php echo $i % 2; ?>">

        <td><?php echo $this->pagination->getRowOffset( $i ); ?> </td>

        <td><?php echo JHtml::_('grid.id', $i, $item->id); ?> </td>

        <td><a href="<?php echo JRoute::_('index.php?option=com_regions&task=region.edit&id=' . $item->id); ?>"> <?php echo $item->treename; ?> </a> </td>


		<td align="center">	<?php echo JHtml::_('jgrid.published', $item->published, $i, 'regions.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>

 </td>

		<td align="center" class="order">

			

			

			<?php if ($canChange) : ?>

						<?php if ($saveOrder) : ?>

							<?php if ($listDirn == 'asc') : ?>

								<span><?php echo $this->pagination->orderUpIcon($i, (@$this->items[$i-1]->catid == $item->catid), 'regions.orderup', 'JLIB_HTML_MOVE_UP', $ordering); ?></span>

								<span><?php echo $this->pagination->orderDownIcon($i, $this->pagination->total, (@$this->items[$i+1]->catid == $item->catid), 'regions.orderdown', 'JLIB_HTML_MOVE_DOWN', $ordering); ?></span>

							<?php elseif ($listDirn == 'desc') : ?>

								<span><?php echo $this->pagination->orderUpIcon($i, (@$this->items[$i-1]->catid == $item->catid), 'regions.orderdown', 'JLIB_HTML_MOVE_UP', $ordering); ?></span>

								<span><?php echo $this->pagination->orderDownIcon($i, $this->pagination->total, (@$this->items[$i+1]->catid == $item->catid), 'regions.orderup', 'JLIB_HTML_MOVE_DOWN', $ordering); ?></span>

							<?php endif; ?>

						<?php endif; ?>

						<?php $disabled = $saveOrder ?  '' : 'disabled="disabled"'; ?>

						<input type="text" name="order[]" size="5" value="<?php echo $item->ordering;?>" <?php echo $disabled; ?> class="text-area-order" />

					<?php else : ?>

						<?php echo $item->ordering; ?>

					<?php endif; ?>

		</td>

		<td align="center"><?php echo $item->created; ?> </td>

		<td align="center"><?php echo $item->id; ?> </td>

      </tr>

      <?php endforeach; ?>

    </tbody>

  </table>

  <div>

	<input type="hidden" name="task" value="" />

	<input type="hidden" name="boxchecked" value="0" />

	<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />

	<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />	

    <?php echo JHtml::_('form.token'); ?> </div>

</form>

